﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MyStore.Orders
{
    public class Cart
    {
        private IList<CartItem> items;

        public Cart()
        {
            items = new List<CartItem>();
        }

        public Cart(string p, string p_2)
        {
            // TODO: Complete member initialization
            this.p = p;
            this.p_2 = p_2;
        }

        public void AddItem(CartItem cartItem)
        {
            items.Add(cartItem);
        }

        const int MIN_SALENUM = 1;
        const int MAX_ITEMCOUNT = 50;
        private string p;
        private string p_2;
        public bool IsValid
        {
            get
            {
                if (items.Any(p => p.Quantity > p.Product.MaxSaleNum || p.Quantity < MIN_SALENUM))
                    return false;
                if (items.Count() > MAX_ITEMCOUNT)
                    return false;
                return true;
            }
        }


        internal void Save()
        {
            throw new NotImplementedException();
        }
    }
}
